using System;

namespace Kaleida.ServiceMonitor.Model.Runtime
{
    public class RequestErrorResult : RequestResult
    {
    	private readonly DateTime errorDateTime;
    	private readonly Exception exception;

        public RequestErrorResult(IOperation operation, DateTime sentOn, DateTime errorDateTime, Exception exception)
            : base(operation, sentOn)
        {
        	this.errorDateTime = errorDateTime;
        	this.exception = exception;
        }

    	public Exception Exception
        {
            get { return exception; }
        }

    	public DateTime ErrorDateTime
    	{
    		get { return errorDateTime; }
    	}

    	public override string ToListItemText()
        {
			return string.Format("Sent at {0:G}:  ({1}) Error occured at {2:G}: {3}", SentOn, Operation.Description, errorDateTime, exception.Message);
        }

        public override string ToClipboardItemText()
        {
			return string.Format("{0:yyyy-MM-dd HH:mm:ss.fff}\t{1}\t{2}", SentOn, exception.Message, Operation.Description);
        }
    }
}